<ResourceDictionary xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:V2TEK.NET.SH.Silverlight.Charts;assembly=V2TEK.NET.SH.Silverlight.Charts"
    xmlns:localTM="clr-namespace:V2TEK.NET.SH.Silverlight.Charts.TimeLineHelper;assembly=V2TEK.NET.SH.Silverlight.Charts"
    xmlns:localGantt="clr-namespace:V2TEK.NET.SH.Silverlight.Charts.GanttHelper;assembly=V2TEK.NET.SH.Silverlight.Charts"
    xmlns:localCore="clr-namespace:V2TEK.NET.SH.Silverlight.Charts.Core;assembly=V2TEK.NET.SH.Silverlight.Charts.Core"
    xmlns:localGrid="clr-namespace:V2TEK.NET.SH.Silverlight.Charts.TreeGridHelper;assembly=V2TEK.NET.SH.Silverlight.Charts"
    xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data">

    <Style TargetType="local:TimeLine">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:TimeLine">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30" />
                            <RowDefinition Height="30" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <localTM:TimeLineViewer Grid.Row="0" x:Name="SummaryTimeLine" />
                        <localTM:TimeLineViewer Grid.Row="1" x:Name="DetailTimeLine" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:GanttPanel">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:GanttPanel">
                    <Grid Grid.Column="1" Grid.Row="1" Background="White">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <localGantt:TaskEntryViewer Visibility="Visible" VerticalAlignment="Top" Grid.Column="0" Grid.Row="0" x:Name="TaskEntryViewer" Margin="0,0,0,0" HorizontalAlignment="Left" />
                        <ScrollBar Orientation="Vertical" Canvas.ZIndex="20" Grid.Column="1" x:Name="VerticalScrollBar" />
                        <ScrollBar Orientation="Horizontal" Canvas.ZIndex="20" Grid.Row="1" x:Name="HorizontalScrollBar" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <local:GridLengthConverter x:Key="GWCvt"></local:GridLengthConverter>
    <local:PercentConverter x:Key="PercentCvt"></local:PercentConverter>
    <Style TargetType="localGantt:SimpleSummaryTaskRenderer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGantt:SimpleSummaryTaskRenderer">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            >
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <TextBlock FontWeight="ExtraBold" Text="{Binding Path=Data.TaskName,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                                <TextBlock Text="{Binding Path=Data.DisplayText,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                            </StackPanel>
                        </ToolTipService.ToolTip>
                        <Grid Height="16">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="mCompletedCol"></ColumnDefinition>
                                <ColumnDefinition x:Name="mUnCompletedCol"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Path Width="16" Height="16" VerticalAlignment="Stretch" Grid.ColumnSpan="3" Stretch="Fill" HorizontalAlignment="Left">
                                <Path.Data>
                                    <PathGeometry >
                                        <PathGeometry.Figures>
                                            <PathFigure StartPoint="0,0" IsClosed="True" IsFilled="True">
                                                <PathFigure.Segments>
                                                    <LineSegment Point="20,0"></LineSegment>
                                                    <LineSegment Point="0,15"></LineSegment>
                                                </PathFigure.Segments>
                                            </PathFigure>
                                        </PathGeometry.Figures>
                                    </PathGeometry>
                                </Path.Data>
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF111111" Offset="0.947"/>
                                        <GradientStop Color="#FFFFFFFF"/>
                                        <GradientStop Color="#FF444444" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Path Width="16" Height="16" VerticalAlignment="Stretch" Grid.ColumnSpan="3" Stretch="Fill" HorizontalAlignment="Right">
                                <Path.Data>
                                    <PathGeometry >
                                        <PathGeometry.Figures>
                                            <PathFigure StartPoint="0,0" IsClosed="True" IsFilled="True">
                                                <PathFigure.Segments>
                                                    <LineSegment Point="20,0"></LineSegment>
                                                    <LineSegment Point="20,15"></LineSegment>
                                                </PathFigure.Segments>
                                            </PathFigure>
                                        </PathGeometry.Figures>
                                    </PathGeometry>
                                </Path.Data>
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF111111" Offset="0.947"/>
                                        <GradientStop Color="#FFFFFFFF"/>
                                        <GradientStop Color="#FF444444" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Rectangle Width="Auto" Height="10" VerticalAlignment="Top" Grid.ColumnSpan="3" Stroke="Black" Stretch="Fill">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF111111" Offset="0.947"/>
                                        <GradientStop Color="#FFFFFFFF"/>
                                        <GradientStop Color="#FF444444" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle Grid.Column="0" Height="9" VerticalAlignment="Top" StrokeThickness="1" Stroke="Green" RadiusX="3" RadiusY="3" Margin="1">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF36FF00" Offset="0.947"/>
                                        <GradientStop Color="White"/>
                                        <GradientStop Color="#FFA6F699" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <TextBlock Grid.Column="0" Height="9" FontSize="8" VerticalAlignment="Top" HorizontalAlignment="Center"  Text="{Binding Path=Data.PercentComplete,Converter={StaticResource PercentCvt}, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localGantt:SimpleTaskRenderer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGantt:SimpleTaskRenderer">
                    <Canvas >
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <TextBlock FontWeight="ExtraBold" Text="{Binding Path=Data.TaskName,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                                <TextBlock Text="{Binding Path=Data.DisplayText,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                            </StackPanel>
                        </ToolTipService.ToolTip>
                        <Grid x:Name="mTaskBar">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions></Grid.RowDefinitions>
                            <Rectangle Grid.Column="0" Grid.ColumnSpan="2" StrokeThickness="1" Stroke="Blue" Width="Auto" RadiusX="3" RadiusY="3" Height="12" Stretch="Fill" Margin="0">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF3600FF" Offset="0.947"/>
                                        <GradientStop Color="White"/>
                                        <GradientStop Color="#FFA699F6" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Grid Grid.Column="0" Grid.ColumnSpan="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="mCompletedCol"></ColumnDefinition>
                                    <ColumnDefinition x:Name="mUnCompletedCol"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Rectangle Height="12" Grid.Column="0" StrokeThickness="1" VerticalAlignment="Stretch" Stroke="Green" RadiusX="3" RadiusY="3" Margin="1">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FF36FF00" Offset="0.947"/>
                                            <GradientStop Color="White"/>
                                            <GradientStop Color="#FFA6F699" Offset="0.412"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="8" Text="{Binding Path=Data.PercentComplete,Converter={StaticResource PercentCvt}, RelativeSource={RelativeSource TemplatedParent}}" />
                            </Grid>
                        </Grid>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock FontSize="12" FontWeight="Bold" Text="{Binding Path=Data.TaskName, RelativeSource={RelativeSource TemplatedParent}}" />
                            <TextBlock Margin="12,0,0,0" FontSize="12" FontWeight="Bold" Text="{Binding Path=Data.Resource.DisplayName, RelativeSource={RelativeSource TemplatedParent}}" />
                        </StackPanel>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localGantt:ConstraintEntryViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGantt:ConstraintEntryViewer">
                    <Border Background="Black"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Rectangle Width="{TemplateBinding Width}" Stretch="Fill" Margin="0" Fill="Yellow"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localGantt:SimpleTaskEntryRenderer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGantt:SimpleTaskEntryRenderer">
                    <StackPanel x:Name="RenderRoot"></StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localGantt:SimpleTaskByResourceEntryRenderer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGantt:SimpleTaskByResourceEntryRenderer">
                    <Canvas >
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <TextBlock FontWeight="ExtraBold" Text="{Binding Path=Data.TaskName,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                                <TextBlock Text="{Binding Path=Data.DisplayText,RelativeSource={RelativeSource TemplatedParent}}"></TextBlock>
                            </StackPanel>
                        </ToolTipService.ToolTip>
                        <Grid x:Name="mTaskBar" Height="{Binding Path=RowHeight,RelativeSource={RelativeSource TemplatedParent}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions></Grid.RowDefinitions>
                            <Rectangle Margin="0,4,0,4" Grid.Column="0" Grid.ColumnSpan="2" StrokeThickness="1" Stroke="Blue" Width="Auto" RadiusX="3" RadiusY="3" Stretch="Fill">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF3600FF" Offset="0.947"/>
                                        <GradientStop Color="White"/>
                                        <GradientStop Color="#FFA699F6" Offset="0.412"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Grid Margin="0,4,0,4" Grid.Column="0" Grid.ColumnSpan="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="mCompletedCol"></ColumnDefinition>
                                    <ColumnDefinition x:Name="mUnCompletedCol"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Rectangle Grid.Column="0" StrokeThickness="1" VerticalAlignment="Stretch" Stroke="Green" RadiusX="3" RadiusY="3" Margin="1">
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FF36FF00" Offset="0.947"/>
                                            <GradientStop Color="White"/>
                                            <GradientStop Color="#FFA6F699" Offset="0.412"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                                <TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="8" Text="{Binding Path=Data.PercentComplete,Converter={StaticResource PercentCvt}, RelativeSource={RelativeSource TemplatedParent}}" />
                            </Grid>
                        </Grid>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock FontSize="12" FontWeight="Bold" Text="{Binding Path=Data.TaskName, RelativeSource={RelativeSource TemplatedParent}}" />
                        </StackPanel>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localGrid:SimpleTaskExpander">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localGrid:SimpleTaskExpander">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Border Grid.Column="0" x:Name="Indention" />
                            <Button Grid.Column="1" Width="Auto" x:Name="ExpanderBtn" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <local:VisibleConverter x:Key="mVsbCvt"></local:VisibleConverter>
    <Style TargetType="local:Gantt">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Gantt">
                    <Border BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}">
                        <Border.Clip>
                            <RectangleGeometry Rect="0,0,10000,10000"></RectangleGeometry>
                        </Border.Clip>
                        <Grid x:Name="TopGrid" VerticalAlignment="Top">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="200" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid Grid.Column="2" VerticalAlignment="Top">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <local:GanttPanel x:Name="GanttPanel" Grid.Row="1"
                                            StartDate="{Binding Path=StartDate, RelativeSource={RelativeSource TemplatedParent}}"
                                            EndDate="{Binding Path=EndDate, RelativeSource={RelativeSource TemplatedParent}}"
                                            RowHeight="{Binding Path=RowHeight, RelativeSource={RelativeSource TemplatedParent}}"
                                            ContentHeight="{Binding Path=ContentHeight, RelativeSource={RelativeSource TemplatedParent}}"
                                            ContentWidth="{Binding Path=ContentWidth, RelativeSource={RelativeSource TemplatedParent}}"
                                            ViewPortHeight ="{Binding Path=GanttViewPortHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                            ViewPortWidth="{Binding Path=GanttViewPortWidth, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                            XPosition="{Binding Path=XPosition, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                            YPosition="{Binding Path=YPosition, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                            DataSource="{Binding Path=DataSource, RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"                                                 
                                            ExpandLevel="{Binding Path=ExpandLevel, RelativeSource={RelativeSource TemplatedParent}}"  
                                            MinDateTimeRangeWidth="{Binding Path=MinDateTimeRangeWidth, RelativeSource={RelativeSource TemplatedParent}}"
                                            />
                                <local:TimeLine x:Name="GanttTimeHeader" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Left"
                                            StartDate="{Binding Path=StartDate, RelativeSource={RelativeSource TemplatedParent}}"
                                            EndDate="{Binding Path=EndDate, RelativeSource={RelativeSource TemplatedParent}}"
                                            ContentWidth="{TemplateBinding ContentWidth}"
                                            ViewPortHeightPerTimeLine ="{Binding Path=TimeLineViewPortHeight, RelativeSource={RelativeSource TemplatedParent}}"
                                            ViewPortWidth="{Binding Path=GanttViewPortWidth, RelativeSource={RelativeSource TemplatedParent}}"
                                            XPosition="{Binding Path=XPosition, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                            MinDateTimeRangeWidth="{Binding Path=MinDateTimeRangeWidth, RelativeSource={RelativeSource TemplatedParent}}"
                                            />

                            </Grid>
                            <local:TreeGrid x:Name="TreeGrid"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Visible"
                                            RowHeight="{Binding Path=RowHeight, RelativeSource={RelativeSource TemplatedParent}}"
                                            YPosition="{Binding Path=YPosition, RelativeSource={RelativeSource TemplatedParent}}"
                                            ViewPortHeight="{Binding Path=GanttViewPortHeight, RelativeSource={RelativeSource TemplatedParent}}"
                                            AutoGenerateColumns="False" Margin="0,0,5,0">

                            </local:TreeGrid>
                            <controls:GridSplitter x:Name="GanttGridSplitter" Grid.Column="0" 
                                               Grid.RowSpan="1"
                                               Width="5"                                                    
                                               ShowsPreview="True"
                                               VerticalAlignment="Stretch"
                                               Background="Gray"></controls:GridSplitter>
                            <Grid Grid.ColumnSpan="2" x:Name="mLoadingGrid" Background="LightBlue" Opacity="0.3" Visibility="{Binding Path=IsLoading,Mode=TwoWay,Converter={StaticResource mVsbCvt},RelativeSource={RelativeSource TemplatedParent}}">
                                <TextBlock Text="Loading..." FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
